//
//  JZHMySelfViewController.m
//  极致荟
//
//  Created by mac on 14-4-8.
//  Copyright (c) 2014年 mac. All rights reserved.
//

#import "JZHMySelfViewController.h"
#import "JZHMyPorfileTableViewCell.h"
#import "JZHMyProfileViewController.h"
#import "JZHPersonaldetailsViewController.h"
#import "JZHMyCollectViewController.h"
#import "JZHVIPViewController.h"
#import "JZHAGViewController.h"
#import "JZHMyBillViewController.h"
#import "JZHMyPingViewController.h"
#import "JZHMyHostViewController.h"
#import "JZHMycodeViewController.h"
@interface JZHMySelfViewController ()
{
    NSArray *arr;
}
@property (weak, nonatomic) IBOutlet UIImageView *vipicon;
@end

@implementation JZHMySelfViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [[JZHTabbarViewController shareInstance] showTabBar2];
    [ImageCache imageUrl:[User defuceUser].userHeadImage UiImageview:self.headimae];
    self.usernaem.text=[User defuceUser].name;
    [[JZHTabbarViewController shareInstance] showTabBar2];
    [self vipiconimage];
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.tableView.tableHeaderView = self.headerView;
    
    [self.headimae.layer setBorderWidth:2];
    [self.headimae.layer setBorderColor:[[UIColor whiteColor] CGColor]];
    [self.headimae.layer setCornerRadius:8];
    [self.headimae.layer setMasksToBounds:YES];
    arr=[[NSArray alloc]initWithObjects:@"我的相册", @"我的收藏",@"我的活动",@"我的评论",nil];
    self.navigationItem.title=@"我";
    
       UIButton *rightButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
    [rightButton addTarget:self action:@selector(rightDrawerButtonPress:) forControlEvents:UIControlEventTouchUpInside];
    [rightButton setImage:[UIImage imageNamed:@"个人信息二维码"] forState:UIControlStateNormal];
    UIBarButtonItem *rightBarButton = [[UIBarButtonItem alloc] initWithCustomView:rightButton];
    self.navigationItem.rightBarButtonItem = rightBarButton;

}
//会员图标显示设置
- (void)vipiconimage
{
    int vip=[User defuceUser].vip;
    if(vip==0)
    {
        if([User defuceUser].sex==1)
        {
            self.vipicon.image=[UIImage imageNamed:@"no1-1"];
        }else
        {
            self.vipicon.image=[UIImage imageNamed:@"no0-1"];
        }
        
        return;
    }
    
    if(vip==1)
    {
        self.vipicon.image=[UIImage imageNamed:@"vip1-1"];
    }else
    {
        self.vipicon.image=[UIImage imageNamed:@"vip2-1"];
    }
}

- (IBAction)pusMyProflie:(id)sender {
    [UINavigationController Pus:self ToViewconeroller:[[JZHMyProfileViewController alloc]init]];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)rightDrawerButtonPress:(UIButton *)but
{

    [UINavigationController Pus:self ToViewconeroller:[[JZHMycodeViewController alloc] init]];
}


#pragma mark ---tableview代理---
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    return arr.count;
    
}



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    
    static NSString *str=@"adf";
    JZHMyPorfileTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:str];
    if(!cell)
    {
        cell=[[[NSBundle mainBundle] loadNibNamed:@"JZHMyPorfileTableViewCell" owner:self options:nil] objectAtIndex:0];
        [cell.image setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@",arr[indexPath.row]]]];
        [cell.lable setText:arr[indexPath.row]];
    }
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    switch (indexPath.row) {
        case 0:
            [UINavigationController Pus:self ToViewconeroller:[JZHPersonaldetailsViewController shareName:[User defuceUser]]];
            break;
        case 1:
            [UINavigationController Pus:self ToViewconeroller:[[JZHMyCollectViewController alloc]init]];
            break;
        case 2:
            //[UINavigationController Pus:self ToViewconeroller:[[JZHVIPViewController alloc]init]];
             [UINavigationController Pus:self ToViewconeroller:[[JZHMyHostViewController alloc]init] ];
            break;
        case 3:
           // [UINavigationController Pus:self ToViewconeroller:[[JZHAGViewController alloc]init]];
            [UINavigationController Pus:self ToViewconeroller:[[JZHMyPingViewController alloc]init]];
            break;
        case 4:
            [UINavigationController Pus:self ToViewconeroller:[[JZHMyBillViewController alloc]init]];
            break;
        case 5:
            [UINavigationController Pus:self ToViewconeroller:[[JZHMyHostViewController alloc]init] ];
            break;
        case 6:
            [UINavigationController Pus:self ToViewconeroller:[[JZHMyPingViewController alloc]init]];
            break;
        case 7:
            [UINavigationController Pus:self ToViewconeroller:[[JZHMyBillViewController alloc]init]];
            break;
        default:
            
            break;
    }
}


@end
